package Models;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class CustomConnection {
	private static String url = "jdbc:mysql://localhost:3306/site_erp";
	private static String user = "root";
	private static String password = "";
	

	private static Connection conn = null;
	
	private CustomConnection() {
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(url,user,password);
		}
		catch (Exception e) {}
	}
	
	public static Connection getConnection() {
		try {
			if (conn == null || conn.isClosed())
				new CustomConnection();
		} catch (SQLException e) {
			new CustomConnection();
		}
		
		return conn;
	}
}